﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PragmaTouchUtils;

namespace eBook.WinApp
{
  [ConfigContentItem]
  [Serializable]
  public class DatabaseOptions
  {
    public string Server { get; set; }
    public string Database { get; set; }    
    public bool IntegratedSecurity { get; set; }
    public string Username { get; set; }
    public string Password { get; set; }

    public DatabaseOptions()
    {

    }

    public string BuildConnectionString()
    {
      StringBuilder sb = new StringBuilder();
      sb.AppendFormat("Data Source={0};", this.Server);
      sb.AppendFormat("Initial Catalog={0};", this.Database);
      if ( this.IntegratedSecurity )
        sb.AppendFormat("Integrated Security={0};", this.IntegratedSecurity);
      else
      {
        sb.AppendFormat("User Id={0};", this.Username);
        sb.AppendFormat("Password={0};", this.Password);
      }
      sb.AppendFormat("MultipleActiveResultSets={0};", true);

      return sb.ToString();
    }
  }


}
